home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / cocktail / front.lha / front / m2c / Scanner.c < prev    next >
C/C++ Source or Header  |  1992-08-18  |  42KB  |  1,524 lines

  1. #include "SYSTEM_.h"
  2.  
  3. #ifndef DEFINITION_Checks
  4. #include "Checks.h"
  5. #endif
  6.  
  7. #ifndef DEFINITION_System
  8. #include "System.h"
  9. #endif
  10.  
  11. #ifndef DEFINITION_General
  12. #include "General.h"
  13. #endif
  14.  
  15. #ifndef DEFINITION_Positions
  16. #include "Positions.h"
  17. #endif
  18.  
  19. #ifndef DEFINITION_IO
  20. #include "IO.h"
  21. #endif
  22.  
  23. #ifndef DEFINITION_DynArray
  24. #include "DynArray.h"
  25. #endif
  26.  
  27. #ifndef DEFINITION_Strings
  28. #include "Strings.h"
  29. #endif
  30.  
  31. #ifndef DEFINITION_Source
  32. #include "Source.h"
  33. #endif
  34.  
  35. #ifndef DEFINITION_Strings
  36. #include "Strings.h"
  37. #endif
  38.  
  39. #ifndef DEFINITION_StringMem
  40. #include "StringMem.h"
  41. #endif
  42.  
  43. #ifndef DEFINITION_Idents
  44. #include "Idents.h"
  45. #endif
  46.  
  47. #ifndef DEFINITION_Lists
  48. #include "Lists.h"
  49. #endif
  50.  
  51. #ifndef DEFINITION_Limits
  52. #include "Limits.h"
  53. #endif
  54.  
  55. #ifndef DEFINITION_WriteTok
  56. #include "WriteTok.h"
  57. #endif
  58.  
  59. #ifndef DEFINITION_Errors
  60. #include "Errors.h"
  61. #endif
  62.  
  63. #ifndef DEFINITION_Scanner
  64. #include "Scanner.h"
  65. #endif
  66.  
  67. INTEGER Scanner_TokenLength;
  68. Scanner_tScanAttribute Scanner_Attribute;
  69. struct Scanner_2 Scanner_ScanTabName;
  70. PROC Scanner_Exit;
  71.  
  72. #define eCharIgnored    10
  73. #define eEolString    11
  74. #define eUnClAction    12
  75. #define eUnClComment    13
  76. #define eUnClString    14
  77. #define SymEqual    1
  78. #define SymColon    2
  79. #define SymPoint    3
  80. #define SymOr    4
  81. #define SymStar    5
  82. #define SymPlus    6
  83. #define SymList    7
  84. #define SymLBrace    8
  85. #define SymRBrace    9
  86. #define SymLBracket    10
  87. #define SymRBracket    11
  88. #define SymEXPORT    12
  89. #define SymGLOBAL    13
  90. #define SymLOCAL    14
  91. #define SymBEGIN    15
  92. #define SymCLOSE    16
  93. #define SymTOKEN    17
  94. #define SymOPER    18
  95. #define SymNONE    19
  96. #define SymLEFT    20
  97. #define SymRIGHT    21
  98. #define SymRULE    22
  99. #define SymPREC    23
  100. #define SymComment    24
  101. #define SymNumber    25
  102. #define SymAction    26
  103. #define SymIdentifier    27
  104. #define SymString    28
  105. #define SymScanner    29
  106. #define SymParser    30
  107. static INTEGER level;
  108. static CARDINAL GetNumber ARGS((Strings_tString *Word));
  109. #define yyTabSpace    8
  110. #define yyDNoState    0
  111. #define yyFileStackSize    16
  112. #define yyInitBufferSize    (1024 * 8 + 256)
  113. #define yyFirstCh    '\0'
  114. #define yyLastCh    ((CHAR)'\177')
  115. #define yyEolCh    '\n'
  116. #define yyEobCh    ((CHAR)'\177')
  117. #define yyDStateCount    163
  118. #define yyTableSize    1997
  119. #define yyEobState    47
  120. #define yyDefaultState    48
  121. #define STD    1
  122. #define token    3
  123. #define rule    5
  124. #define code    7
  125. #define Str1    9
  126. #define Str2    11
  127. #define CStr1    13
  128. #define CStr2    15
  129. #define comment    17
  130. #define comment2    19
  131. typedef SHORTCARD yyTableElmt;
  132. typedef yyTableElmt yyStateRange;
  133. typedef yyTableElmt yyTableRange;
  134. typedef struct S_1 {
  135.     yyStateRange Check, Next;
  136. } yyCombType;
  137. typedef yyCombType *yyCombTypePtr;
  138. typedef struct S_2 {
  139.     CHAR A[1000000 + 1];
  140. } *yytChBufferPtr;
  141. typedef CHAR yyChRange;
  142. static struct S_3 {
  143.     LONGCARD A[yyDStateCount + 1];
  144. } yyBasePtr;
  145. static struct S_4 {
  146.     yyStateRange A[yyDStateCount + 1];
  147. } yyDefault;
  148. static struct S_5 {
  149.     yyCombType A[yyTableSize + 1];
  150. } yyComb;
  151. static struct S_6 {
  152.     yyStateRange A[yyDStateCount + 1];
  153. } yyEobTrans;
  154. static struct S_7 {
  155.     CHAR A[yyLastCh + 1];
  156. } yyToLower, yyToUpper;
  157. static struct S_8 {
  158.     yyStateRange A[1000000 + 1];
  159. } *yyStateStack;
  160. static LONGINT yyStateStackSize;
  161. static yyStateRange yyStartState;
  162. static yyStateRange yyPreviousStart;
  163. static CHAR yyCh;
  164. static System_tFile yySourceFile;
  165. static BOOLEAN yyEof;
  166. static yytChBufferPtr yyChBufferPtr;
  167. static INTEGER yyChBufferStart;
  168. static LONGINT yyChBufferSize;
  169. static INTEGER yyChBufferIndex;
  170. static INTEGER yyBytesRead;
  171. static CARDINAL yyLineCount;
  172. static INTEGER yyLineStart;
  173. static SHORTCARD yyFileStackPtr;
  174. static struct S_9 {
  175.     struct S_10 {
  176.         System_tFile SourceFile;
  177.         BOOLEAN Eof;
  178.         yytChBufferPtr ChBufferPtr;
  179.         INTEGER ChBufferStart;
  180.         LONGINT ChBufferSize;
  181.         INTEGER ChBufferIndex;
  182.         INTEGER BytesRead;
  183.         CARDINAL LineCount;
  184.         INTEGER LineStart;
  185.     } A[yyFileStackSize - 1 + 1];
  186. } yyFileStack;
  187. static void yyInitialize ARGS(());
  188. static void yyStart ARGS((yyStateRange State));
  189. static void yyPrevious ARGS(());
  190. static void yyEcho ARGS(());
  191. static void yyLess ARGS((INTEGER n));
  192. static void yyTab ARGS(());
  193. static void yyTab1 ARGS((INTEGER a));
  194. static void yyTab2 ARGS((INTEGER a, INTEGER b));
  195. static void yyEol ARGS((INTEGER Column));
  196. static void output ARGS((CHAR c));
  197. static void unput ARGS((CHAR c));
  198. static CHAR input ARGS(());
  199. static void yyGetTables ARGS(());
  200. struct S_12 {
  201.     yyTableRange A[yyDStateCount + 1];
  202. };
  203. static CARDINAL yyGetTable ARGS((System_tFile TableFile, ADDRESS Address));
  204. static void yyErrorMessage ARGS((SHORTCARD ErrorCode));
  205. static void yyExit ARGS(());
  206.  
  207.  
  208. void Scanner_ErrorAttribute
  209. # ifdef __STDC__
  210. (INTEGER Token, Scanner_tScanAttribute *Attr)
  211. # else
  212. (Token, Attr)
  213. INTEGER Token;
  214. Scanner_tScanAttribute *Attr;
  215. # endif
  216. {
  217.   Strings_tString s;
  218.  
  219.   Strings_ArrayToString((STRING)"-error-", 7L, &s);
  220.   switch (Token) {
  221.   case 0:;
  222.     break;
  223.   case 1:;
  224.   case 2:;
  225.   case 3:;
  226.   case 4:;
  227.   case 5:;
  228.   case 6:;
  229.   case 7:;
  230.   case 8:;
  231.   case 9:;
  232.   case 10:;
  233.   case 11:;
  234.   case 12:;
  235.   case 13:;
  236.   case 14:;
  237.   case 15:;
  238.   case 16:;
  239.   case 17:;
  240.   case 18:;
  241.   case 19:;
  242.   case 20:;
  243.   case 21:;
  244.   case 22:;
  245.   case 23:;
  246.     Attr->Mode = Scanner_Keys;
  247.     break;
  248.   case 24:;
  249.     Attr->Mode = Scanner_Comment;
  250.     Lists_MakeList(&Attr->U_1.V_1.Comm);
  251.     break;
  252.   case 25:;
  253.     Attr->Mode = Scanner_Number;
  254.     Attr->U_1.V_2.Value = Limits_MaxShortCard;
  255.     break;
  256.   case 26:;
  257.     Attr->Mode = Scanner_Action;
  258.     Lists_MakeList(&Attr->U_1.V_3.Act);
  259.     break;
  260.   case 27:;
  261.   case 28:;
  262.     Attr->Mode = Scanner_Symbol;
  263.     Attr->U_1.V_4.Sym = Idents_MakeIdent(&s);
  264.     break;
  265.   }
  266. }
  267.  
  268. static CARDINAL GetNumber
  269. # ifdef __STDC__
  270. (Strings_tString *Word)
  271. # else
  272. (Word)
  273. Strings_tString *Word;
  274. # endif
  275. {
  276.   CARDINAL i, n, d;
  277.  
  278.   i = 0;
  279.   n = 0;
  280.   while (i < Strings_Length(Word)) {
  281.     i = i + 1;
  282.     d = ORD(Strings_Char(Word, (Strings_tStringIndex)i)) - ORD('0');
  283.     if (n > Limits_MaxShortCard / 10 || n * 10 > Limits_MaxShortCard - d) {
  284.       return Limits_MaxShortCard;
  285.     }
  286.     n = n * 10 + d;
  287.   }
  288.   return n;
  289. }
  290.  
  291. INTEGER Scanner_GetToken
  292. # ifdef __STDC__
  293. ()
  294. # else
  295. ()
  296. # endif
  297. {
  298.   yyStateRange yyState;
  299.   yyCombTypePtr yyTablePtr;
  300.   BOOLEAN yyRestartFlag;
  301.   INTEGER yyi, yySource, yyTarget, yyChBufferFree;
  302.   Strings_tString Word, String, LastWord;
  303.   CHAR c;
  304.   SHORTCARD PrevState;
  305.  
  306.   for (;;) {
  307.     yyState = yyStartState;
  308.     Scanner_TokenLength = 0;
  309.     for (;;) {
  310.       for (;;) {
  311.         yyTablePtr = (yyCombTypePtr)(yyBasePtr.A[yyState] + ORD(yyChBufferPtr->A[yyChBufferIndex]) * sizeof(yyCombType));
  312.         if (yyTablePtr->Check != yyState) {
  313.           yyState = yyDefault.A[yyState];
  314.           if (yyState == yyDNoState) {
  315.             goto EXIT_3;
  316.           }
  317.         } else {
  318.           yyState = yyTablePtr->Next;
  319.           INC(Scanner_TokenLength);
  320.           yyStateStack->A[Scanner_TokenLength] = yyState;
  321.           INC(yyChBufferIndex);
  322.         }
  323.       } EXIT_3:;
  324.       for (;;) {
  325.         switch (yyStateStack->A[Scanner_TokenLength]) {
  326.         case 163:;
  327.           Scanner_Attribute.Position.Line = yyLineCount;
  328.           Scanner_Attribute.Position.Column = yyChBufferIndex - yyLineStart - Scanner_TokenLength;
  329.           Scanner_Attribute.Mode = Scanner_Keys;
  330.           return SymEqual;
  331.           yyRestartFlag = FALSE;
  332.           goto EXIT_4;
  333.           break;
  334.         case 162:;
  335.           Scanner_Attribute.Position.Line = yyLineCount;
  336.           Scanner_Attribute.Position.Column = yyChBufferIndex - yyLineStart - Scanner_TokenLength;
  337.           Scanner_Attribute.Mode = Scanner_Keys;
  338.           return SymColon;
  339.           yyRestartFlag = FALSE;
  340.           goto EXIT_4;
  341.           break;
  342.         case 161:;
  343.           Scanner_Attribute.Position.Line = yyLineCount;
  344.           Scanner_Attribute.Position.Column = yyChBufferIndex - yyLineStart - Scanner_TokenLength;
  345.           Scanner_Attribute.Mode = Scanner_Keys;
  346.           return SymPoint;
  347.           yyRestartFlag = FALSE;
  348.           goto EXIT_4;
  349.           break;
  350.         case 157:;
  351.           Scanner_Attribute.Position.Line = yyLineCount;
  352.           Scanner_Attribute.Position.Column = yyChBufferIndex - yyLineStart - Scanner_TokenLength;
  353.           Scanner_Attribute.Mode = Scanner_Keys;
  354.           return SymOr;
  355.           yyRestartFlag = FALSE;
  356.           goto EXIT_4;
  357.           break;
  358.         case 160:;
  359.           Scanner_Attribute.Position.Line = yyLineCount;
  360.           Scanner_Attribute.Position.Column = yyChBufferIndex - yyLineStart - Scanner_TokenLength;
  361.           Scanner_Attribute.Mode = Scanner_Keys;
  362.           return SymStar;
  363.           yyRestartFlag = FALSE;
  364.           goto EXIT_4;
  365.           break;
  366.         case 159:;
  367.           Scanner_Attribute.Position.Line = yyLineCount;
  368.           Scanner_Attribute.Position.Column = yyChBufferIndex - yyLineStart - Scanner_TokenLength;
  369.           Scanner_Attribute.Mode = Scanner_Keys;
  370.           return SymPlus;
  371.           yyRestartFlag = FALSE;
  372.           goto EXIT_4;
  373.           break;
  374.         case 158:;
  375.           Scanner_Attribute.Position.Line = yyLineCount;
  376.           Scanner_Attribute.Position.Column = yyChBufferIndex - yyLineStart - Scanner_TokenLength;
  377.           Scanner_Attribute.Mode = Scanner_Keys;
  378.           return SymList;
  379.           yyRestartFlag = FALSE;
  380.           goto EXIT_4;
  381.           break;
  382.         case 156:;
  383.           Scanner_Attribute.Position.Line = yyLineCount;
  384.           Scanner_Attribute.Position.Column = yyChBufferIndex - yyLineStart - Scanner_TokenLength;
  385.           Scanner_Attribute.Mode = Scanner_Keys;
  386.           return SymLBrace;
  387.           yyRestartFlag = FALSE;
  388.           goto EXIT_4;
  389.           break;
  390.         case 155:;
  391.           Scanner_Attribute.Position.Line = yyLineCount;
  392.           Scanner_Attribute.Position.Column = yyChBufferIndex - yyLineStart - Scanner_TokenLength;
  393.           Scanner_Attribute.Mode = Scanner_Keys;
  394.           return SymRBrace;
  395.           yyRestartFlag = FALSE;
  396.           goto EXIT_4;
  397.           break;
  398.         case 154:;
  399.           Scanner_Attribute.Position.Line = yyLineCount;
  400.           Scanner_Attribute.Position.Column = yyChBufferIndex - yyLineStart - Scanner_TokenLength;
  401.           Scanner_Attribute.Mode = Scanner_Keys;
  402.           return SymLBracket;
  403.           yyRestartFlag = FALSE;
  404.           goto EXIT_4;
  405.           break;
  406.         case 153:;
  407.           Scanner_Attribute.Position.Line = yyLineCount;
  408.           Scanner_Attribute.Position.Column = yyChBufferIndex - yyLineStart - Scanner_TokenLength;
  409.           Scanner_Attribute.Mode = Scanner_Keys;
  410.           return SymRBracket;
  411.           yyRestartFlag = FALSE;
  412.           goto EXIT_4;
  413.           break;
  414.         case 152:;
  415.           Scanner_Attribute.Position.Line = yyLineCount;
  416.           Scanner_Attribute.Position.Column = yyChBufferIndex - yyLineStart - Scanner_TokenLength;
  417.           Scanner_Attribute.Mode = Scanner_Keys;
  418.           return SymScanner;
  419.           yyRestartFlag = FALSE;
  420.           goto EXIT_4;
  421.           break;
  422.         case 145:;
  423.           Scanner_Attribute.Position.Line = yyLineCount;
  424.           Scanner_Attribute.Position.Column = yyChBufferIndex - yyLineStart - Scanner_TokenLength;
  425.           Scanner_Attribute.Mode = Scanner_Keys;
  426.           return SymParser;
  427.           yyRestartFlag = FALSE;
  428.           goto EXIT_4;
  429.           break;
  430.         case 139:;
  431.           Scanner_Attribute.Position.Line = yyLineCount;
  432.           Scanner_Attribute.Position.Column = yyChBufferIndex - yyLineStart - Scanner_TokenLength;
  433.           Scanner_Attribute.Mode = Scanner_Keys;
  434.           return SymEXPORT;
  435.           yyRestartFlag = FALSE;
  436.           goto EXIT_4;
  437.           break;
  438.         case 133:;
  439.           Scanner_Attribute.Position.Line = yyLineCount;
  440.           Scanner_Attribute.Position.Column = yyChBufferIndex - yyLineStart - Scanner_TokenLength;
  441.           Scanner_Attribute.Mode = Scanner_Keys;
  442.           return SymGLOBAL;
  443.           yyRestartFlag = FALSE;
  444.           goto EXIT_4;
  445.           break;
  446.         case 127:;
  447.           Scanner_Attribute.Position.Line = yyLineCount;
  448.           Scanner_Attribute.Position.Column = yyChBufferIndex - yyLineStart - Scanner_TokenLength;
  449.           Scanner_Attribute.Mode = Scanner_Keys;
  450.           return SymLOCAL;
  451.           yyRestartFlag = FALSE;
  452.           goto EXIT_4;
  453.           break;
  454.         case 122:;
  455.           Scanner_Attribute.Position.Line = yyLineCount;
  456.           Scanner_Attribute.Position.Column = yyChBufferIndex - yyLineStart - Scanner_TokenLength;
  457.           Scanner_Attribute.Mode = Scanner_Keys;
  458.           return SymBEGIN;
  459.           yyRestartFlag = FALSE;
  460.           goto EXIT_4;
  461.           break;
  462.         case 117:;
  463.           Scanner_Attribute.Position.Line = yyLineCount;
  464.           Scanner_Attribute.Position.Column = yyChBufferIndex - yyLineStart - Scanner_TokenLength;
  465.           Scanner_Attribute.Mode = Scanner_Keys;
  466.           return SymCLOSE;
  467.           yyRestartFlag = FALSE;
  468.           goto EXIT_4;
  469.           break;
  470.         case 112:;
  471.           Scanner_Attribute.Position.Line = yyLineCount;
  472.           Scanner_Attribute.Position.Column = yyChBufferIndex - yyLineStart - Scanner_TokenLength;
  473.           Scanner_Attribute.Mode = Scanner_Keys;
  474.           yyStart(token);
  475.           return SymTOKEN;
  476.           yyRestartFlag = FALSE;
  477.           goto EXIT_4;
  478.           break;
  479.         case 107:;
  480.           Scanner_Attribute.Position.Line = yyLineCount;
  481.           Scanner_Attribute.Position.Column = yyChBufferIndex - yyLineStart - Scanner_TokenLength;
  482.           Scanner_Attribute.Mode = Scanner_Keys;
  483.           return SymOPER;
  484.           yyRestartFlag = FALSE;
  485.           goto EXIT_4;
  486.           break;
  487.         case 103:;
  488.           Scanner_Attribute.Position.Line = yyLineCount;
  489.           Scanner_Attribute.Position.Column = yyChBufferIndex - yyLineStart - Scanner_TokenLength;
  490.           Scanner_Attribute.Mode = Scanner_Keys;
  491.           return SymNONE;
  492.           yyRestartFlag = FALSE;
  493.           goto EXIT_4;
  494.           break;
  495.         case 99:;
  496.           Scanner_Attribute.Position.Line = yyLineCount;
  497.           Scanner_Attribute.Position.Column = yyChBufferIndex - yyLineStart - Scanner_TokenLength;
  498.           Scanner_Attribute.Mode = Scanner_Keys;
  499.           return SymLEFT;
  500.           yyRestartFlag = FALSE;
  501.           goto EXIT_4;
  502.           break;
  503.         case 95:;
  504.           Scanner_Attribute.Position.Line = yyLineCount;
  505.           Scanner_Attribute.Position.Column = yyChBufferIndex - yyLineStart - Scanner_TokenLength;
  506.           Scanner_Attribute.Mode = Scanner_Keys;
  507.           return SymRIGHT;
  508.           yyRestartFlag = FALSE;
  509.           goto EXIT_4;
  510.           break;
  511.         case 91:;
  512.           Scanner_Attribute.Position.Line = yyLineCount;
  513.           Scanner_Attribute.Position.Column = yyChBufferIndex - yyLineStart - Scanner_TokenLength;
  514.           Scanner_Attribute.Mode = Scanner_Keys;
  515.           yyStart(rule);
  516.           return SymRULE;
  517.           yyRestartFlag = FALSE;
  518.           goto EXIT_4;
  519.           break;
  520.         case 87:;
  521.           Scanner_Attribute.Position.Line = yyLineCount;
  522.           Scanner_Attribute.Position.Column = yyChBufferIndex - yyLineStart - Scanner_TokenLength;
  523.           Scanner_Attribute.Mode = Scanner_Keys;
  524.           return SymPREC;
  525.           yyRestartFlag = FALSE;
  526.           goto EXIT_4;
  527.           break;
  528.         case 33:;
  529.           Scanner_Attribute.Position.Line = yyLineCount;
  530.           Scanner_Attribute.Position.Column = yyChBufferIndex - yyLineStart - Scanner_TokenLength;
  531.           Scanner_Attribute.Mode = Scanner_Number;
  532.           Scanner_GetWord(&Word);
  533.           Scanner_Attribute.U_1.V_4.Sym = Idents_MakeIdent(&Word);
  534.           Scanner_Attribute.U_1.V_2.Value = GetNumber(&Word);
  535.           return SymNumber;
  536.           yyRestartFlag = FALSE;
  537.           goto EXIT_4;
  538.           break;
  539.         case 32:;
  540.           Scanner_Attribute.Position.Line = yyLineCount;
  541.           Scanner_Attribute.Position.Column = yyChBufferIndex - yyLineStart - Scanner_TokenLength;
  542.           Scanner_Attribute.Mode = Scanner_Keys;
  543.           Scanner_GetWord(&Word);
  544.           Strings_SubString(&Word, 2, (Strings_tStringIndex)Strings_Length(&Word), &String);
  545.           Scanner_Attribute.U_1.V_4.Sym = Idents_MakeIdent(&String);
  546.           return SymIdentifier;
  547.           yyRestartFlag = FALSE;
  548.           goto EXIT_4;
  549.           break;
  550.         case 30:;
  551.         case 84:;
  552.         case 85:;
  553.         case 86:;
  554.         case 88:;
  555.         case 89:;
  556.         case 90:;
  557.         case 92:;
  558.         case 93:;
  559.         case 94:;
  560.         case 96:;
  561.         case 97:;
  562.         case 98:;
  563.         case 100:;
  564.         case 101:;
  565.         case 102:;
  566.         case 104:;
  567.         case 105:;
  568.         case 106:;
  569.         case 108:;
  570.         case 109:;
  571.         case 110:;
  572.         case 111:;
  573.         case 113:;
  574.         case 114:;
  575.         case 115:;
  576.         case 116:;
  577.         case 118:;
  578.         case 119:;
  579.         case 120:;
  580.         case 121:;
  581.         case 123:;
  582.         case 124:;
  583.         case 125:;
  584.         case 126:;
  585.         case 128:;
  586.         case 129:;
  587.         case 130:;
  588.         case 131:;
  589.         case 132:;
  590.         case 134:;
  591.         case 135:;
  592.         case 136:;
  593.         case 137:;
  594.         case 138:;
  595.         case 140:;
  596.         case 141:;
  597.         case 142:;
  598.         case 143:;
  599.         case 144:;
  600.         case 146:;
  601.         case 147:;
  602.         case 148:;
  603.         case 149:;
  604.         case 150:;
  605.         case 151:;
  606.           Scanner_Attribute.Position.Line = yyLineCount;
  607.           Scanner_Attribute.Position.Column = yyChBufferIndex - yyLineStart - Scanner_TokenLength;
  608.           Scanner_Attribute.Mode = Scanner_Keys;
  609.           Scanner_GetWord(&Word);
  610.           Scanner_Attribute.U_1.V_4.Sym = Idents_MakeIdent(&Word);
  611.           return SymIdentifier;
  612.           yyRestartFlag = FALSE;
  613.           goto EXIT_4;
  614.           break;
  615.         case 83:;
  616.           Scanner_Attribute.Position.Line = yyLineCount;
  617.           Scanner_Attribute.Position.Column = yyChBufferIndex - yyLineStart - Scanner_TokenLength;
  618.           PrevState = yyStartState;
  619.           yyStart(code);
  620.           Scanner_GetWord(&LastWord);
  621.           Scanner_Attribute.Mode = Scanner_Action;
  622.           Lists_MakeList(&Scanner_Attribute.U_1.V_3.Act);
  623.           level = 1;
  624.           yyRestartFlag = FALSE;
  625.           goto EXIT_4;
  626.           break;
  627.         case 31:;
  628.           yyRestartFlag = FALSE;
  629.           goto EXIT_4;
  630.           break;
  631.         case 81:;
  632.         case 82:;
  633.           Scanner_Attribute.Position.Line = yyLineCount;
  634.           Scanner_Attribute.Position.Column = yyChBufferIndex - yyLineStart - Scanner_TokenLength;
  635.           Scanner_GetWord(&String);
  636.           Scanner_Attribute.Mode = Scanner_Symbol;
  637.           if (WriteTok_Language == WriteTok_C) {
  638.             yyStart(CStr1);
  639.           } else {
  640.             yyStart(Str1);
  641.           }
  642.           yyRestartFlag = FALSE;
  643.           goto EXIT_4;
  644.           break;
  645.         case 79:;
  646.         case 80:;
  647.           Scanner_Attribute.Position.Line = yyLineCount;
  648.           Scanner_Attribute.Position.Column = yyChBufferIndex - yyLineStart - Scanner_TokenLength;
  649.           Scanner_GetWord(&String);
  650.           Scanner_Attribute.Mode = Scanner_Symbol;
  651.           if (WriteTok_Language == WriteTok_C) {
  652.             yyStart(CStr2);
  653.           } else {
  654.             yyStart(Str2);
  655.           }
  656.           yyRestartFlag = FALSE;
  657.           goto EXIT_4;
  658.           break;
  659.         case 27:;
  660.         case 40:;
  661.         case 53:;
  662.           Scanner_GetWord(&Word);
  663.           Strings_Concatenate(&String, &Word);
  664.           yyRestartFlag = FALSE;
  665.           goto EXIT_4;
  666.           break;
  667.         case 25:;
  668.         case 38:;
  669.         case 54:;
  670.           Scanner_GetWord(&Word);
  671.           Strings_Concatenate(&String, &Word);
  672.           yyRestartFlag = FALSE;
  673.           goto EXIT_4;
  674.           break;
  675.         case 24:;
  676.         case 37:;
  677.         case 44:;
  678.         case 55:;
  679.           Scanner_GetWord(&Word);
  680.           Strings_Concatenate(&String, &Word);
  681.           yyRestartFlag = FALSE;
  682.           goto EXIT_4;
  683.           break;
  684.         case 23:;
  685.         case 36:;
  686.         case 43:;
  687.         case 56:;
  688.           Scanner_GetWord(&Word);
  689.           Strings_Concatenate(&String, &Word);
  690.           yyRestartFlag = FALSE;
  691.           goto EXIT_4;
  692.           break;
  693.         case 78:;
  694.           Scanner_GetWord(&Word);
  695.           Strings_Concatenate(&String, &Word);
  696.           yyEol(0L);
  697.           yyRestartFlag = FALSE;
  698.           goto EXIT_4;
  699.           break;
  700.         case 45:;
  701.         case 77:;
  702.           Strings_Append(&String, Strings_Char(&String, 1));
  703.           yyPrevious();
  704.           if (yyStartState == code) {
  705.             Strings_Concatenate(&LastWord, &String);
  706.           } else {
  707.             Scanner_Attribute.U_1.V_4.Sym = Idents_MakeIdent(&String);
  708.             return SymString;
  709.           }
  710.           yyRestartFlag = FALSE;
  711.           goto EXIT_4;
  712.           break;
  713.         case 39:;
  714.         case 76:;
  715.           Strings_Append(&String, Strings_Char(&String, 1));
  716.           yyPrevious();
  717.           if (yyStartState == code) {
  718.             Strings_Concatenate(&LastWord, &String);
  719.           } else {
  720.             Scanner_Attribute.U_1.V_4.Sym = Idents_MakeIdent(&String);
  721.             return SymString;
  722.           }
  723.           yyRestartFlag = FALSE;
  724.           goto EXIT_4;
  725.           break;
  726.         case 75:;
  727.           Strings_Append(&String, '\t');
  728.           yyTab();
  729.           yyRestartFlag = FALSE;
  730.           goto EXIT_4;
  731.           break;
  732.         case 74:;
  733.           Scanner_Attribute.Position.Line = yyLineCount;
  734.           Scanner_Attribute.Position.Column = yyChBufferIndex - yyLineStart - Scanner_TokenLength;
  735.           Errors_ErrorMessage((LONGCARD)eEolString, (LONGCARD)Errors_eError, Scanner_Attribute.Position);
  736.           Strings_Append(&String, Strings_Char(&String, 1));
  737.           yyEol(0L);
  738.           yyPrevious();
  739.           if (yyStartState == code) {
  740.             Strings_Concatenate(&LastWord, &String);
  741.           } else {
  742.             Scanner_Attribute.U_1.V_4.Sym = Idents_MakeIdent(&String);
  743.             return SymString;
  744.           }
  745.           yyRestartFlag = FALSE;
  746.           goto EXIT_4;
  747.           break;
  748.         case 73:;
  749.           Scanner_Attribute.Position.Line = yyLineCount;
  750.           Scanner_Attribute.Position.Column = yyChBufferIndex - yyLineStart - Scanner_TokenLength;
  751.           yyStart(comment);
  752.           Scanner_GetWord(&LastWord);
  753.           Scanner_Attribute.Mode = Scanner_Comment;
  754.           Lists_MakeList(&Scanner_Attribute.U_1.V_1.Comm);
  755.           level = 1;
  756.           yyRestartFlag = FALSE;
  757.           goto EXIT_4;
  758.           break;
  759.         case 71:;
  760.           yyStart(comment2);
  761.           yyRestartFlag = FALSE;
  762.           goto EXIT_4;
  763.           break;
  764.         case 29:;
  765.         case 42:;
  766.         case 70:;
  767.         case 72:;
  768.           Scanner_Attribute.Position.Line = yyLineCount;
  769.           Scanner_Attribute.Position.Column = yyChBufferIndex - yyLineStart - Scanner_TokenLength;
  770.           Scanner_GetWord(&Word);
  771.           c = Strings_Char(&Word, 1);
  772.           Errors_ErrorMessageI((LONGCARD)eCharIgnored, (LONGCARD)Errors_eWarning, Scanner_Attribute.Position, (LONGCARD)Errors_eCharacter, ADR(c));
  773.           yyRestartFlag = FALSE;
  774.           goto EXIT_4;
  775.           break;
  776.         case 28:;
  777.         case 41:;
  778.         case 52:;
  779.           Scanner_GetWord(&Word);
  780.           Strings_Concatenate(&LastWord, &Word);
  781.           yyRestartFlag = FALSE;
  782.           goto EXIT_4;
  783.           break;
  784.         case 26:;
  785.           Scanner_Attribute.Position.Line = yyLineCount;
  786.           Scanner_Attribute.Position.Column = yyChBufferIndex - yyLineStart - Scanner_TokenLength;
  787.           c = '\\';
  788.           Errors_ErrorMessageI((LONGCARD)eCharIgnored, (LONGCARD)Errors_eWarning, Scanner_Attribute.Position, (LONGCARD)Errors_eCharacter, ADR(c));
  789.           yyRestartFlag = FALSE;
  790.           goto EXIT_4;
  791.           break;
  792.         case 69:;
  793.           yyTab();
  794.           Scanner_GetWord(&Word);
  795.           Strings_Concatenate(&LastWord, &Word);
  796.           yyRestartFlag = FALSE;
  797.           goto EXIT_4;
  798.           break;
  799.         case 68:;
  800.           Scanner_GetWord(&Word);
  801.           Strings_Concatenate(&LastWord, &Word);
  802.           Lists_Append(&Scanner_Attribute.U_1.V_3.Act, (ADDRESS)StringMem_PutString(&LastWord));
  803.           Strings_AssignEmpty(&LastWord);
  804.           yyEol(0L);
  805.           yyRestartFlag = FALSE;
  806.           goto EXIT_4;
  807.           break;
  808.         case 67:;
  809.           Scanner_GetWord(&Word);
  810.           Strings_Concatenate(&LastWord, &Word);
  811.           INC(level);
  812.           yyRestartFlag = FALSE;
  813.           goto EXIT_4;
  814.           break;
  815.         case 66:;
  816.           DEC(level);
  817.           Scanner_GetWord(&Word);
  818.           Strings_Concatenate(&LastWord, &Word);
  819.           if (level == 0) {
  820.             yyStart(PrevState);
  821.             Lists_Append(&Scanner_Attribute.U_1.V_3.Act, (ADDRESS)StringMem_PutString(&LastWord));
  822.             return SymAction;
  823.           }
  824.           yyRestartFlag = FALSE;
  825.           goto EXIT_4;
  826.           break;
  827.         case 65:;
  828.           Scanner_GetWord(&Word);
  829.           Strings_Concatenate(&LastWord, &Word);
  830.           INC(level);
  831.           yyRestartFlag = FALSE;
  832.           goto EXIT_4;
  833.           break;
  834.         case 63:;
  835.           DEC(level);
  836.           Scanner_GetWord(&Word);
  837.           Strings_Concatenate(&LastWord, &Word);
  838.           if (level == 0) {
  839.             yyPrevious();
  840.             Lists_Append(&Scanner_Attribute.U_1.V_1.Comm, (ADDRESS)StringMem_PutString(&LastWord));
  841.             return SymComment;
  842.           }
  843.           yyRestartFlag = FALSE;
  844.           goto EXIT_4;
  845.           break;
  846.         case 22:;
  847.         case 35:;
  848.         case 57:;
  849.         case 62:;
  850.         case 64:;
  851.           Scanner_GetWord(&Word);
  852.           Strings_Concatenate(&LastWord, &Word);
  853.           yyRestartFlag = FALSE;
  854.           goto EXIT_4;
  855.           break;
  856.         case 61:;
  857.           yyTab();
  858.           Scanner_GetWord(&Word);
  859.           Strings_Concatenate(&LastWord, &Word);
  860.           yyRestartFlag = FALSE;
  861.           goto EXIT_4;
  862.           break;
  863.         case 60:;
  864.           Scanner_GetWord(&Word);
  865.           Strings_Concatenate(&LastWord, &Word);
  866.           Lists_Append(&Scanner_Attribute.U_1.V_1.Comm, (ADDRESS)StringMem_PutString(&LastWord));
  867.           Strings_AssignEmpty(&LastWord);
  868.           yyEol(0L);
  869.           yyRestartFlag = FALSE;
  870.           goto EXIT_4;
  871.           break;
  872.         case 21:;
  873.         case 34:;
  874.         case 58:;
  875.           yyRestartFlag = FALSE;
  876.           goto EXIT_4;
  877.           break;
  878.         case 59:;
  879.           yyPrevious();
  880.           yyRestartFlag = FALSE;
  881.           goto EXIT_4;
  882.           break;
  883.         case 51:;
  884.           while (yyChBufferPtr->A[yyChBufferIndex] == ' ') {
  885.             INC(yyChBufferIndex);
  886.           }
  887.           yyRestartFlag = FALSE;
  888.           goto EXIT_4;
  889.           break;
  890.         case 50:;
  891.           DEC1(yyLineStart, 7 - (yyChBufferIndex - yyLineStart - 2) % 8);
  892.           yyRestartFlag = FALSE;
  893.           goto EXIT_4;
  894.           break;
  895.         case 49:;
  896.           INC(yyLineCount);
  897.           yyLineStart = yyChBufferIndex - 1;
  898.           yyRestartFlag = FALSE;
  899.           goto EXIT_4;
  900.           break;
  901.         case 1:;
  902.         case 2:;
  903.         case 3:;
  904.         case 4:;
  905.         case 5:;
  906.         case 6:;
  907.         case 7:;
  908.         case 8:;
  909.         case 9:;
  910.         case 10:;
  911.         case 11:;
  912.         case 12:;
  913.         case 13:;
  914.         case 14:;
  915.         case 15:;
  916.         case 16:;
  917.         case 17:;
  918.         case 18:;
  919.         case 19:;
  920.         case 20:;
  921.         case 46:;
  922.           DEC(yyChBufferIndex);
  923.           DEC(Scanner_TokenLength);
  924.           break;
  925.         case 48:;
  926.           Scanner_Attribute.Position.Line = yyLineCount;
  927.           Scanner_Attribute.Position.Column = yyChBufferIndex - yyLineStart;
  928.           INC(yyChBufferIndex);
  929.           Scanner_TokenLength = 1;
  930.           IO_WriteC((System_tFile)IO_StdOutput, yyChBufferPtr->A[yyChBufferIndex - 1]);
  931.           yyRestartFlag = FALSE;
  932.           goto EXIT_4;
  933.           break;
  934.         case yyDNoState:;
  935.           yyGetTables();
  936.           yyStateStack->A[0] = yyDefaultState;
  937.           if (yyFileStackPtr == 0) {
  938.             yyInitialize();
  939.             yySourceFile = System_StdInput;
  940.           }
  941.           yyRestartFlag = FALSE;
  942.           goto EXIT_4;
  943.           break;
  944.         case 47:;
  945.           DEC(yyChBufferIndex);
  946.           DEC(Scanner_TokenLength);
  947.           if (Scanner_TokenLength == 0) {
  948.             yyState = yyStartState;
  949.           } else {
  950.             yyState = yyStateStack->A[Scanner_TokenLength];
  951.           }
  952.           if (yyChBufferIndex != yyChBufferStart + yyBytesRead) {
  953.             yyState = yyEobTrans.A[yyState];
  954.             if (yyState != yyDNoState) {
  955.               INC(yyChBufferIndex);
  956.               INC(Scanner_TokenLength);
  957.               yyStateStack->A[Scanner_TokenLength] = yyState;
  958.               yyRestartFlag = TRUE;
  959.               goto EXIT_4;
  960.             }
  961.           } else {
  962.             yySource = yyChBufferIndex - Scanner_TokenLength - 1;
  963.             yyTarget = General_MaxAlign - Scanner_TokenLength % General_MaxAlign - 1;
  964.             if (yySource != yyTarget) {
  965.               {
  966.                 LONGINT B_1 = 1, B_2 = Scanner_TokenLength;
  967.  
  968.                 if (B_1 <= B_2)
  969.                   for (yyi = B_1;; yyi += 1) {
  970.                     yyChBufferPtr->A[yyTarget + yyi] = yyChBufferPtr->A[yySource + yyi];
  971.                     if (yyi >= B_2) break;
  972.                   }
  973.               }
  974.               DEC1(yyLineStart, yySource - yyTarget);
  975.               yyChBufferStart = yyTarget + Scanner_TokenLength + 1;
  976.             } else {
  977.               yyChBufferStart = yyChBufferIndex;
  978.             }
  979.             if (!yyEof) {
  980.               yyChBufferFree = General_Exp2(General_Log2(yyChBufferSize - 4 - General_MaxAlign - Scanner_TokenLength));
  981.               if (yyChBufferFree < yyChBufferSize / 8) {
  982.                 DynArray_ExtendArray((ADDRESS *)&yyChBufferPtr, &yyChBufferSize, (LONGINT)sizeof(CHAR));
  983.                 if (yyChBufferPtr == NIL) {
  984.                   yyErrorMessage(1);
  985.                 }
  986.                 yyChBufferFree = General_Exp2(General_Log2(yyChBufferSize - 4 - General_MaxAlign - Scanner_TokenLength));
  987.                 if (yyStateStackSize < yyChBufferSize) {
  988.                   DynArray_ExtendArray((ADDRESS *)&yyStateStack, &yyStateStackSize, (LONGINT)sizeof(yyStateRange));
  989.                   if (yyStateStack == NIL) {
  990.                     yyErrorMessage(1);
  991.                   }
  992.                 }
  993.               }
  994.               yyChBufferIndex = yyChBufferStart;
  995.               yyBytesRead = Source_GetLine(yySourceFile, ADR(yyChBufferPtr->A[yyChBufferIndex]), (LONGCARD)yyChBufferFree);
  996.               if (yyBytesRead <= 0) {
  997.                 yyBytesRead = 0;
  998.                 yyEof = TRUE;
  999.               }
  1000.               yyChBufferPtr->A[yyChBufferStart + yyBytesRead] = yyEobCh;
  1001.               yyChBufferPtr->A[yyChBufferStart + yyBytesRead + 1] = '\0';
  1002.               yyRestartFlag = TRUE;
  1003.               goto EXIT_4;
  1004.             }
  1005.             if (Scanner_TokenLength == 0) {
  1006.               Scanner_Attribute.Position.Line = yyLineCount;
  1007.               Scanner_Attribute.Position.Column = yyChBufferIndex - yyLineStart;
  1008.               Scanner_CloseFile();
  1009.               if (yyFileStackPtr == 0) {
  1010.                 switch (yyStartState) {
  1011.                 case code:;
  1012.                   Errors_ErrorMessage((LONGCARD)eUnClAction, (LONGCARD)Errors_eError, Scanner_Attribute.Position);
  1013.                   break;
  1014.                 case comment:;
  1015.                 case comment2:;
  1016.                   Errors_ErrorMessage((LONGCARD)eUnClComment, (LONGCARD)Errors_eError, Scanner_Attribute.Position);
  1017.                   break;
  1018.                 case Str1:;
  1019.                 case Str2:;
  1020.                 case CStr1:;
  1021.                 case CStr2:;
  1022.                   Errors_ErrorMessage((LONGCARD)eUnClString, (LONGCARD)Errors_eError, Scanner_Attribute.Position);
  1023.                   break;
  1024.                 default :
  1025.                   break;
  1026.                 }
  1027.               }
  1028.               if (yyFileStackPtr == 0) {
  1029.                 return Scanner_EofToken;
  1030.               }
  1031.               yyRestartFlag = FALSE;
  1032.               goto EXIT_4;
  1033.             }
  1034.           }
  1035.           break;
  1036.         default :
  1037.           yyErrorMessage(0);
  1038.           break;
  1039.         }
  1040.       } EXIT_4:;
  1041.       if (yyRestartFlag) {
  1042.       } else {
  1043.         goto EXIT_2;
  1044.       }
  1045.     } EXIT_2:;
  1046.   } EXIT_1:;
  1047. }
  1048.  
  1049. void Scanner_BeginFile
  1050. # ifdef __STDC__
  1051. (CHAR FileName[], LONGCARD O_1)
  1052. # else
  1053. (FileName, O_1)
  1054. CHAR FileName[];
  1055. LONGCARD O_1;
  1056. # endif
  1057. {
  1058.   OPEN_ARRAY_LOCALS
  1059.  
  1060.   ALLOC_OPEN_ARRAYS(O_1 * sizeof(CHAR), 1)
  1061.   COPY_OPEN_ARRAY(FileName, O_1, CHAR)
  1062.   if (yyStateStack->A[0] == yyDNoState) {
  1063.     yyGetTables();
  1064.     yyStateStack->A[0] = yyDefaultState;
  1065.   }
  1066.   yyInitialize();
  1067.   yySourceFile = Source_BeginSource(FileName, O_1);
  1068.   FREE_OPEN_ARRAYS
  1069. }
  1070.  
  1071. static void yyInitialize
  1072. # ifdef __STDC__
  1073. ()
  1074. # else
  1075. ()
  1076. # endif
  1077. {
  1078.   if (yyFileStackPtr >= yyFileStackSize) {
  1079.     yyErrorMessage(3);
  1080.   }
  1081.   INC(yyFileStackPtr);
  1082.   {
  1083.     register struct S_10 *W_1 = &yyFileStack.A[yyFileStackPtr - 1];
  1084.  
  1085.     W_1->SourceFile = yySourceFile;
  1086.     W_1->Eof = yyEof;
  1087.     W_1->ChBufferPtr = yyChBufferPtr;
  1088.     W_1->ChBufferStart = yyChBufferStart;
  1089.     W_1->ChBufferSize = yyChBufferSize;
  1090.     W_1->ChBufferIndex = yyChBufferIndex;
  1091.     W_1->BytesRead = yyBytesRead;
  1092.     W_1->LineCount = yyLineCount;
  1093.     W_1->LineStart = yyLineStart;
  1094.   }
  1095.   yyChBufferSize = yyInitBufferSize;
  1096.   DynArray_MakeArray((ADDRESS *)&yyChBufferPtr, &yyChBufferSize, (LONGINT)sizeof(CHAR));
  1097.   yyChBufferStart = General_MaxAlign;
  1098.   yyChBufferPtr->A[yyChBufferStart - 1] = yyEolCh;
  1099.   yyChBufferPtr->A[yyChBufferStart] = yyEobCh;
  1100.   yyChBufferPtr->A[yyChBufferStart + 1] = '\0';
  1101.   yyChBufferIndex = yyChBufferStart;
  1102.   yyEof = FALSE;
  1103.   yyBytesRead = 0;
  1104.   yyLineCount = 1;
  1105.   yyLineStart = yyChBufferStart - 1;
  1106. }
  1107.  
  1108. void Scanner_CloseFile
  1109. # ifdef __STDC__
  1110. ()
  1111. # else
  1112. ()
  1113. # endif
  1114. {
  1115.   if (yyFileStackPtr == 0) {
  1116.     yyErrorMessage(4);
  1117.   }
  1118.   Source_CloseSource(yySourceFile);
  1119.   DynArray_ReleaseArray((ADDRESS *)&yyChBufferPtr, &yyChBufferSize, (LONGINT)sizeof(CHAR));
  1120.   {
  1121.     register struct S_10 *W_2 = &yyFileStack.A[yyFileStackPtr - 1];
  1122.  
  1123.     yySourceFile = W_2->SourceFile;
  1124.     yyEof = W_2->Eof;
  1125.     yyChBufferPtr = W_2->ChBufferPtr;
  1126.     yyChBufferStart = W_2->ChBufferStart;
  1127.     yyChBufferSize = W_2->ChBufferSize;
  1128.     yyChBufferIndex = W_2->ChBufferIndex;
  1129.     yyBytesRead = W_2->BytesRead;
  1130.     yyLineCount = W_2->LineCount;
  1131.     yyLineStart = W_2->LineStart;
  1132.   }
  1133.   DEC(yyFileStackPtr);
  1134. }
  1135.  
  1136. void Scanner_GetWord
  1137. # ifdef __STDC__
  1138. (Strings_tString *Word)
  1139. # else
  1140. (Word)
  1141. Strings_tString *Word;
  1142. # endif
  1143. {
  1144.   INTEGER i, WordStart;
  1145.  
  1146.   WordStart = yyChBufferIndex - Scanner_TokenLength - 1;
  1147.   {
  1148.     LONGINT B_3 = 1, B_4 = Scanner_TokenLength;
  1149.  
  1150.     if (B_3 <= B_4)
  1151.       for (i = B_3;; i += 1) {
  1152.         Word->Chars.A[i] = yyChBufferPtr->A[WordStart + i];
  1153.         if (i >= B_4) break;
  1154.       }
  1155.   }
  1156.   Word->Length = Scanner_TokenLength;
  1157. }
  1158.  
  1159. void Scanner_GetLower
  1160. # ifdef __STDC__
  1161. (Strings_tString *Word)
  1162. # else
  1163. (Word)
  1164. Strings_tString *Word;
  1165. # endif
  1166. {
  1167.   INTEGER i, WordStart;
  1168.  
  1169.   WordStart = yyChBufferIndex - Scanner_TokenLength - 1;
  1170.   {
  1171.     LONGINT B_5 = 1, B_6 = Scanner_TokenLength;
  1172.  
  1173.     if (B_5 <= B_6)
  1174.       for (i = B_5;; i += 1) {
  1175.         Word->Chars.A[i] = yyToLower.A[yyChBufferPtr->A[WordStart + i]];
  1176.         if (i >= B_6) break;
  1177.       }
  1178.   }
  1179.   Word->Length = Scanner_TokenLength;
  1180. }
  1181.  
  1182. void Scanner_GetUpper
  1183. # ifdef __STDC__
  1184. (Strings_tString *Word)
  1185. # else
  1186. (Word)
  1187. Strings_tString *Word;
  1188. # endif
  1189. {
  1190.   INTEGER i, WordStart;
  1191.  
  1192.   WordStart = yyChBufferIndex - Scanner_TokenLength - 1;
  1193.   {
  1194.     LONGINT B_7 = 1, B_8 = Scanner_TokenLength;
  1195.  
  1196.     if (B_7 <= B_8)
  1197.       for (i = B_7;; i += 1) {
  1198.         Word->Chars.A[i] = yyToUpper.A[yyChBufferPtr->A[WordStart + i]];
  1199.         if (i >= B_8) break;
  1200.       }
  1201.   }
  1202.   Word->Length = Scanner_TokenLength;
  1203. }
  1204.  
  1205. static void yyStart
  1206. # ifdef __STDC__
  1207. (yyStateRange State)
  1208. # else
  1209. (State)
  1210. yyStateRange State;
  1211. # endif
  1212. {
  1213.   yyPreviousStart = yyStartState;
  1214.   yyStartState = State;
  1215. }
  1216.  
  1217. static void yyPrevious
  1218. # ifdef __STDC__
  1219. ()
  1220. # else
  1221. ()
  1222. # endif
  1223. {
  1224.   yyStateRange s;
  1225.  
  1226.   s = yyStartState;
  1227.   yyStartState = yyPreviousStart;
  1228.   yyPreviousStart = s;
  1229. }
  1230.  
  1231. static void yyEcho
  1232. # ifdef __STDC__
  1233. ()
  1234. # else
  1235. ()
  1236. # endif
  1237. {
  1238.   INTEGER i;
  1239.  
  1240.   {
  1241.     LONGINT B_9 = yyChBufferIndex - Scanner_TokenLength, B_10 = yyChBufferIndex - 1;
  1242.  
  1243.     if (B_9 <= B_10)
  1244.       for (i = B_9;; i += 1) {
  1245.         IO_WriteC((System_tFile)IO_StdOutput, yyChBufferPtr->A[i]);
  1246.         if (i >= B_10) break;
  1247.       }
  1248.   }
  1249. }
  1250.  
  1251. static void yyLess
  1252. # ifdef __STDC__
  1253. (INTEGER n)
  1254. # else
  1255. (n)
  1256. INTEGER n;
  1257. # endif
  1258. {
  1259.   DEC1(yyChBufferIndex, Scanner_TokenLength - n);
  1260.   Scanner_TokenLength = n;
  1261. }
  1262.  
  1263. static void yyTab
  1264. # ifdef __STDC__
  1265. ()
  1266. # else
  1267. ()
  1268. # endif
  1269. {
  1270.   DEC1(yyLineStart, yyTabSpace - 1 - (yyChBufferIndex - yyLineStart - 2) % yyTabSpace);
  1271. }
  1272.  
  1273. static void yyTab1
  1274. # ifdef __STDC__
  1275. (INTEGER a)
  1276. # else
  1277. (a)
  1278. INTEGER a;
  1279. # endif
  1280. {
  1281.   DEC1(yyLineStart, yyTabSpace - 1 - (yyChBufferIndex - yyLineStart - Scanner_TokenLength + a - 1) % yyTabSpace);
  1282. }
  1283.  
  1284. static void yyTab2
  1285. # ifdef __STDC__
  1286. (INTEGER a, INTEGER b)
  1287. # else
  1288. (a, b)
  1289. INTEGER a, b;
  1290. # endif
  1291. {
  1292.   DEC1(yyLineStart, yyTabSpace - 1 - (yyChBufferIndex - yyLineStart - Scanner_TokenLength + a - 1) % yyTabSpace);
  1293. }
  1294.  
  1295. static void yyEol
  1296. # ifdef __STDC__
  1297. (INTEGER Column)
  1298. # else
  1299. (Column)
  1300. INTEGER Column;
  1301. # endif
  1302. {
  1303.   INC(yyLineCount);
  1304.   yyLineStart = yyChBufferIndex - 1 - Column;
  1305. }
  1306.  
  1307. static void output
  1308. # ifdef __STDC__
  1309. (CHAR c)
  1310. # else
  1311. (c)
  1312. CHAR c;
  1313. # endif
  1314. {
  1315.   IO_WriteC((System_tFile)IO_StdOutput, c);
  1316. }
  1317.  
  1318. static void unput
  1319. # ifdef __STDC__
  1320. (CHAR c)
  1321. # else
  1322. (c)
  1323. CHAR c;
  1324. # endif
  1325. {
  1326.   DEC(yyChBufferIndex);
  1327.   yyChBufferPtr->A[yyChBufferIndex] = c;
  1328. }
  1329.  
  1330. static CHAR input
  1331. # ifdef __STDC__
  1332. ()
  1333. # else
  1334. ()
  1335. # endif
  1336. {
  1337.   if (yyChBufferIndex == yyChBufferStart + yyBytesRead) {
  1338.     if (!yyEof) {
  1339.       DEC1(yyLineStart, yyBytesRead);
  1340.       yyChBufferIndex = 0;
  1341.       yyChBufferStart = 0;
  1342.       yyBytesRead = Source_GetLine(yySourceFile, (ADDRESS)yyChBufferPtr, (LONGCARD)General_Exp2(General_Log2(yyChBufferSize)));
  1343.       if (yyBytesRead <= 0) {
  1344.         yyBytesRead = 0;
  1345.         yyEof = TRUE;
  1346.       }
  1347.       yyChBufferPtr->A[yyBytesRead] = yyEobCh;
  1348.       yyChBufferPtr->A[yyBytesRead + 1] = '\0';
  1349.     }
  1350.   }
  1351.   if (yyChBufferIndex == yyChBufferStart + yyBytesRead) {
  1352.     return '\0';
  1353.   } else {
  1354.     INC(yyChBufferIndex);
  1355.     return yyChBufferPtr->A[yyChBufferIndex - 1];
  1356.   }
  1357. }
  1358.  
  1359. void Scanner_BeginScanner
  1360. # ifdef __STDC__
  1361. ()
  1362. # else
  1363. ()
  1364. # endif
  1365. {
  1366. }
  1367.  
  1368. void Scanner_CloseScanner
  1369. # ifdef __STDC__
  1370. ()
  1371. # else
  1372. ()
  1373. # endif
  1374. {
  1375. }
  1376.  
  1377. static void yyGetTables
  1378. # ifdef __STDC__
  1379. ()
  1380. # else
  1381. ()
  1382. # endif
  1383. {
  1384.   CARDINAL BlockSize, j, n;
  1385.   System_tFile TableFile;
  1386.   yyStateRange i;
  1387.   struct S_12 Base;
  1388.  
  1389.   BlockSize = 64000 / sizeof(yyCombType);
  1390.   TableFile = OpenInput(Scanner_ScanTabName.A, 128L);
  1391.   Checks_ErrorCheck((STRING)"yyGetTables.OpenInput", 21L, TableFile);
  1392.   if (yyGetTable(TableFile, ADR(Base)) / sizeof(yyTableElmt) - 1 != yyDStateCount || yyGetTable(TableFile, ADR(yyDefault)) / sizeof(yyTableElmt) - 1 != yyDStateCount || yyGetTable(TableFile, ADR(yyEobTrans)) / sizeof(yyTableElmt) - 1 != yyDStateCount) {
  1393.     yyErrorMessage(2);
  1394.   }
  1395.   n = 0;
  1396.   j = 0;
  1397.   while (j <= yyTableSize) {
  1398.     INC1(n, yyGetTable(TableFile, ADR(yyComb.A[j])) / sizeof(yyCombType));
  1399.     INC1(j, BlockSize);
  1400.   }
  1401.   if (n != yyTableSize + 1) {
  1402.     yyErrorMessage(2);
  1403.   }
  1404.   Close(TableFile);
  1405.   for (i = 0; i <= yyDStateCount; i += 1) {
  1406.     yyBasePtr.A[i] = (LONGCARD)ADR(yyComb.A[Base.A[i]]);
  1407.   }
  1408. }
  1409.  
  1410. static CARDINAL yyGetTable
  1411. # ifdef __STDC__
  1412. (System_tFile TableFile, ADDRESS Address)
  1413. # else
  1414. (TableFile, Address)
  1415. System_tFile TableFile;
  1416. ADDRESS Address;
  1417. # endif
  1418. {
  1419.   INTEGER N;
  1420.   yyTableElmt Length;
  1421.  
  1422.   N = Read(TableFile, ADR(Length), (LONGCARD)sizeof(yyTableElmt));
  1423.   Checks_ErrorCheck((STRING)"yyGetTable.Read1", 16L, N);
  1424.   N = Read(TableFile, Address, (LONGCARD)Length);
  1425.   Checks_ErrorCheck((STRING)"yyGetTable.Read2", 16L, N);
  1426.   return Length;
  1427. }
  1428.  
  1429. static void yyErrorMessage
  1430. # ifdef __STDC__
  1431. (SHORTCARD ErrorCode)
  1432. # else
  1433. (ErrorCode)
  1434. SHORTCARD ErrorCode;
  1435. # endif
  1436. {
  1437.   Positions_WritePosition((System_tFile)IO_StdError, Scanner_Attribute.Position);
  1438.   switch (ErrorCode) {
  1439.   case 0:;
  1440.     IO_WriteS((System_tFile)IO_StdError, (STRING)": Scanner: internal error", 25L);
  1441.     break;
  1442.   case 1:;
  1443.     IO_WriteS((System_tFile)IO_StdError, (STRING)": Scanner: out of memory", 24L);
  1444.     break;
  1445.   case 2:;
  1446.     IO_WriteS((System_tFile)IO_StdError, (STRING)": Scanner: table mismatch", 25L);
  1447.     break;
  1448.   case 3:;
  1449.     IO_WriteS((System_tFile)IO_StdError, (STRING)": Scanner: too many nested include files", 40L);
  1450.     break;
  1451.   case 4:;
  1452.     IO_WriteS((System_tFile)IO_StdError, (STRING)": Scanner: file stack underflow (too many calls of CloseFile)", 61L);
  1453.     break;
  1454.   }
  1455.   IO_WriteNl((System_tFile)IO_StdError);
  1456.   (*Scanner_Exit)();
  1457. }
  1458.  
  1459. static void yyExit
  1460. # ifdef __STDC__
  1461. ()
  1462. # else
  1463. ()
  1464. # endif
  1465. {
  1466.   IO_CloseIO();
  1467.   Exit(1L);
  1468. }
  1469.  
  1470. void BEGIN_Scanner()
  1471. {
  1472.   static BOOLEAN has_been_called = FALSE;
  1473.  
  1474.   if (!has_been_called) {
  1475.     has_been_called = TRUE;
  1476.  
  1477.     BEGIN_Strings();
  1478.     BEGIN_StringMem();
  1479.     BEGIN_Idents();
  1480.     BEGIN_Rules();
  1481.     BEGIN_Lists();
  1482.     BEGIN_Positions();
  1483.     BEGIN_Checks();
  1484.     BEGIN_System();
  1485.     BEGIN_General();
  1486.     BEGIN_Positions();
  1487.     BEGIN_IO();
  1488.     BEGIN_DynArray();
  1489.     BEGIN_Strings();
  1490.     BEGIN_Source();
  1491.     BEGIN_Strings();
  1492.     BEGIN_StringMem();
  1493.     BEGIN_Idents();
  1494.     BEGIN_Lists();
  1495.     BEGIN_Limits();
  1496.     BEGIN_WriteTok();
  1497.     BEGIN_Errors();
  1498.  
  1499.     (void)strncpy((char *)Scanner_ScanTabName.A, "Scanner.Tab", sizeof(Scanner_ScanTabName.A));
  1500.     Scanner_Exit = yyExit;
  1501.     yyFileStackPtr = 0;
  1502.     yyStartState = 1;
  1503.     yyPreviousStart = 1;
  1504.     yyBasePtr.A[yyStartState] = (LONGCARD)ADR(yyComb.A[0]);
  1505.     yyDefault.A[yyStartState] = yyDNoState;
  1506.     yyComb.A[0].Check = yyDNoState;
  1507.     yyChBufferPtr = (yytChBufferPtr)ADR(yyComb.A[0]);
  1508.     yyChBufferIndex = 1;
  1509.     yyStateStackSize = yyInitBufferSize;
  1510.     DynArray_MakeArray((ADDRESS *)&yyStateStack, &yyStateStackSize, (LONGINT)sizeof(yyStateRange));
  1511.     yyStateStack->A[0] = yyDNoState;
  1512.     for (yyCh = yyFirstCh; yyCh <= yyLastCh; yyCh += 1) {
  1513.       yyToLower.A[yyCh] = yyCh;
  1514.     }
  1515.     yyToUpper = yyToLower;
  1516.     for (yyCh = 'A'; yyCh <= 'Z'; yyCh += 1) {
  1517.       yyToLower.A[yyCh] = CHR(ORD(yyCh) - ORD('A') + ORD('a'));
  1518.     }
  1519.     for (yyCh = 'a'; yyCh <= 'z'; yyCh += 1) {
  1520.       yyToUpper.A[yyCh] = CHR(ORD(yyCh) - ORD('a') + ORD('A'));
  1521.     }
  1522.   }
  1523. }
  1524.